﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication3
{
    public partial class Form1 : Form
    {
        int operand1 = 0, operand2 = 0, operation=0;
        int state = 1;
        public Form1()
        {
            InitializeComponent();
        }

       

        private void button15_Click(object sender, EventArgs e)
        {
            int resault = 0;
            state = 1;
            operand2 = Convert.ToInt32(textBox1.Text);
            if (operation == 1)
            {
                resault = operand1 + operand2;
            }
            if (operation == 2)
            {
                resault = operand1 - operand2;
            }
            if (operation == 3)
            {
                resault = operand1 * operand2;
            }
            if (operation == 4)
            {
                resault = operand1 / operand2;
            }
            textBox1.Text = "" + resault;

        }

       

        private void button_1_Click(object sender, EventArgs e)
        {
            if (state == 1)
            {
                operand1 *= 10;
                operand1 += 1;
                textBox1.Text = "" + operand1;
            }
            else
             if (state==2) 
            {
                operand2 *= 10;
                operand2 += 1;
                textBox1.Text = "" + operand2;
            }
        }

        private void button_0_Click(object sender, EventArgs e)
        {
            if (state == 1)
            {
                operand1 *= 10;
                operand1 += 0;
                textBox1.Text = "" + operand1;
            }
            else
                if (state == 2)
            {
                operand2 *= 10;
                operand2 += 0;
                textBox1.Text = "" + operand2;
            }
        }

        private void button_3_Click(object sender, EventArgs e)
        {
            if (state == 1)
            {
                operand1 *= 10;
                operand1 += 3;
                textBox1.Text = "" + operand1;
            }
            else
                if (state == 2)
                {
                    operand2 *= 10;
                    operand2 += 3;
                    textBox1.Text = "" + operand2;
                }
        }

        private void button_2_Click(object sender, EventArgs e)
        {
            if (state == 1)
            {
                operand1 *= 10;
                operand1 += 2;
                textBox1.Text = "" + operand1;
            }
            else
                if (state == 2)
                {
                    operand2 *= 10;
                    operand2 += 2;
                    textBox1.Text = "" + operand2;
                }
        }

        private void button_5_Click(object sender, EventArgs e)
        {
            if (state == 1)
            {
                operand1 *= 10;
                operand1 += 5;
                textBox1.Text = "" + operand1;
            }
            else
                if (state == 2)
                {
                    operand2 *= 10;
                    operand2 += 5;
                    textBox1.Text = "" + operand2;
                }
        }

        private void button_4_Click(object sender, EventArgs e)
        {
            if (state == 1)
            {
                operand1 *= 10;
                operand1 += 4;
                textBox1.Text = "" + operand1;
            }
            else
                if (state == 2)
                {
                    operand2 *= 10;
                    operand2 += 4;
                    textBox1.Text = "" + operand2;
                }
        }

        private void button_6_Click(object sender, EventArgs e)
        {
            if (state == 1)
            {
                operand1 *= 10;
                operand1 += 6;
                textBox1.Text = "" + operand1;
            }
            else
                if (state == 2)
                {
                    operand2 *= 10;
                    operand2 += 6;
                    textBox1.Text = "" + operand2;
                }
        }

        private void button_7_Click(object sender, EventArgs e)
        {
            if (state == 1)
            {
                operand1 *= 10;
                operand1 += 7;
                textBox1.Text = "" + operand1;
            }
            else
                if (state == 2)
                {
                    operand2 *= 10;
                    operand2 += 7;
                    textBox1.Text = "" + operand2;
                }
        }

        private void button_8_Click(object sender, EventArgs e)
        {
            if (state == 1)
            {
                operand1 *= 10;
                operand1 += 8;
                textBox1.Text = "" + operand1;
            }
            else
                if (state == 2)
                {
                    operand2 *= 10;
                    operand2 += 8;
                    textBox1.Text = "" + operand2;
                }
        }

        private void button_9_Click(object sender, EventArgs e)
        {
            if (state == 1)
            {
                operand1 *= 10;
                operand1 += 9;
                textBox1.Text = "" + operand1;
            }
            else
                if (state == 2)
                {
                    operand2 *= 10;
                    operand2 += 9;
                    textBox1.Text = "" + operand2;
                }
        }

        private void buttonPlus_Click(object sender, EventArgs e)
        {
            operation = 1;
            state = 2;
            operand1 = Convert.ToInt32(textBox1.Text);
            textBox1.Text = "";
        }

        private void buttonMinus_Click(object sender, EventArgs e)
        {
            operation = 2;
            state = 2;
            operand1 = Convert.ToInt32(textBox1.Text);
            textBox1.Text = "";
        }

        private void buttonYmnogit_Click(object sender, EventArgs e)
        {
            operation = 3;
            state = 2;
            operand1 = Convert.ToInt32(textBox1.Text);
            textBox1.Text = "";
        }

        private void buttonDelit_Click(object sender, EventArgs e)
        {
            operation = 4;
            state = 2;
            operand1 = Convert.ToInt32(textBox1.Text);
            textBox1.Text = "";
        }


    }
}
